﻿using M.Warehouse.API.Application.Command.ReservoirsCommand;
using M.Warehouse.Repository.WarehouseInterface;
using MediatR;

namespace M.Warehouse.API.Application.CommandHandlers.ReservoirsHandlers
{
    /// <summary>
    /// 添加库区中介者
    /// </summary>
    public class ReservoirsCreateCommandHandlers : IRequestHandler<ReservoirsCreateCommand, int>
    {
        /// <summary>
        /// 库区接口
        /// </summary>
        private readonly IReservoirsWRepository _repository;
        /// <summary>
        /// 构造函数注入
        /// </summary>
        /// <param name="repository"></param>
        public ReservoirsCreateCommandHandlers(IReservoirsWRepository repository)
        {
            _repository = repository;
        }
        /// <summary>
        /// 添加库区
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<int> Handle(ReservoirsCreateCommand request, CancellationToken cancellationToken)
        {
            return await _repository.AddAsync(request);
        }
    }
}
